﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Runtime.Serialization;
using System.Web.Mvc;
using System.ComponentModel;

namespace EmrDatastructure
{
    [DataContract()]
    public partial class EmrDemographic
    {
        [DataMember]
        [Timestamp]
        [HiddenInput(DisplayValue = false)]
        public byte[] VersionNumber { get; set; }   // binary[8] not null

        [DataMember]
        [Required, StringLength(20)]
        public string Id { get; set; }

        [DataMember]
        [Required, StringLength(30)]
        [DisplayName("Preferred Language")]
        public string PreferredLanguage { get; set; }
        [DataMember]
        [Required, StringLength(10)]
        public string Gender { get; set; }
        [DataMember]
        [Required, StringLength(30)]
        public string Race { get; set; }
        [DataMember]
        [Required, StringLength(30)]
        public string Ethnicity { get; set; }
        [DataMember]
        [Required]
        public DateTime DateOfBirth { get; set; }

        [DataMember]
        [Required, StringLength(30)]
        public string LastName { get; set; }
        [DataMember]
        [Required, StringLength(30)]
        public string FirstName { get; set; }

        [IgnoreDataMember]
        public virtual ICollection<EmrProblem> EmrProblems { get; set; }
        [IgnoreDataMember]
        public virtual ICollection<EmrSmoking> EmrSmoking { get; set; }
    }
}
/*
[DateOfBirth(MinAge = 0, MaxAge = 150)] 
 * public DateTime DateOfBirth { get; set; }  
 * // ...  public class DateOfBirthAttribute : ValidationAttribute 
 * {     public int MinAge { get; set; }     
 * public int MaxAge { get; set; }      
 * public override bool IsValid(object value)     
 * {         
 * if (value == null)             
 * return true;          
 * var val = (DateTime)value;          
 * if (val.AddYears(MinAge) > DateTime.Now)             
 * return false;          
 * return (val.AddYears(MaxAge) > DateTime.Now);     
 * } }  * 
 */

